/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package proyecto2;


import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.border.Border;

/**
 *
 * @author damian
 */
public class Celda extends JLabel {
    int num;
   int fila,columna;
    
    Icon icono;
    Image fondo;
    static final int alto_celda=40;
    static final int ancho_celda=40;
   

    public Celda(int num, int fila,int columna) {
        this.num = num;
        this.fila = fila;
        this.columna=columna;
        
        this.setBorder(BorderFactory.createTitledBorder(""));
        this.setOpaque(true);
        this.setBackground(new Color(74, 155, 201));
        
        //this.repaint();
        //this.setIcon(new ImageIcon(getClass().getResource("/proyecto2/tanque_icon.png")));
    }
    public static Image[] recortar(File image,int col){
        
        int w=0;
        Image imag[]=new Image[col];// contiene las imagenes dividias
        //BufferedImage a= new BufferedImage(img.getWidth(null), h, BufferedImage.TYPE_INT_RGB);
        try {
            BufferedImage a = ImageIO.read(image);// leer la imagen
            
        int x=0;
        int y=0;
        int h=a.getHeight(null);
        
         //   a.getGraphics().drawImage(img, x, y, null);
            w=a.getWidth()/col;
            for (int i = 0; i < col; i++) {
                imag[i] = a.getSubimage(x, y, w, h).getScaledInstance(ancho_celda, alto_celda, Image.SCALE_DEFAULT);// recorta la imagen y redimensiona
                x += w;
                System.out.println(i);
            }
        } catch (IOException iOException) {
            iOException.printStackTrace();
        }
        
        return imag;
        
    }


    
}
